Joining tables allows a layer with the attributes of both source layers to be created. Joins can be based on common attributes or common location (spatial join).
The joined fields are displayed as a new view rather than actually added to the layer. However the join is saved with the project and it will be reloaded each time the project is opened. To permanently add the joined fields to the layer, it must be saved as a new file. To do this, right click on the layer in the Layer Panel and select Save As.
This is because databases are generally designed to be more permanent data repositories than spreadsheets. Therefore their structure shouldn’t be changed for short term projects. Queries can be run and saved without affecting the underlying data.
Join on Common Attributes:-
This method is similar to ArcGIS’ Joins and Relates function. This is done by creating a Vector Join in the layer’s Properties box:-
- Right click on the layer in the Layer Panel
- Select Properties to open the Properties dialogue box
- Select the Join tab
- Press the + button to create a new Vector Join:-
Add Vector Join in QGIS
The Add Vector Join dialogue box opens:-
- Join Layer – the layer that the join will be to
- Join Field – the layer in the Join Layer that contains the common attribute
- Target Field – the field in the currently selected layer that contains the common attribute
Join By Location (Spatial Join)
This function creates a new shapefile containing the geometry of the target layer and the attributes of both layers. The join is based on the Joining layer overlapping or intersecting the target layer:-
- Use the menus to select Vector, Data Management Tools; Join Attributes by Location
- The Join Attributes by Location box opens, select:-
- Select the Target vector Layer (the layer to update)
- Select Join Vector Layer (the layer that will provide the new data)
- Attribute Summary. This determines the action when a target feature is overlapped by multiple join features:-Take the attributes of the first located feature.
- Take a summary of intersecting features
- Output Shapefile – the file that will contain the new data.
Join By Location (Spatial Join) in QGIS